;(function(){
    var methods = {
        alert:function(options){
            // 设置参数           
            var settings = $.extend({
                'title':'这是标题栏',
                'backgroundColor':'red',
                'width':'200px',
                'height':'300px',
                'shadow':[true,0.4]
            },options);
            var lay = this;
            $(lay).fadeIn();
            $(lay).find(".layer-title").css('backgroundColor',settings.backgroundColor);
            $(lay).find(".layer-title .layer-h3").text(settings.title);
            $(lay).css({'width':settings.width,'height':settings.height,'z-index':'3'});
            var title_h = $(lay).find(".layer-title").get(0).offsetHeight;
            $(lay).find(".layer-body").css('height',parseInt(settings.height)-title_h);
            //设置阴影遮罩
            if(settings.shadow[0]){          
                var shadow_div = $("<div class='shadow-box'></div>");
                shadow_div.appendTo($("body"));
                shadow_div.fadeIn();
                shadow_div.css({'position':'absolute','left':'0','top':'0','bottom':'0','right':'0','background-color':'rgba(0,0,0,'+settings.shadow[1]+')','z-index':'2'})
            }
            $(lay).find(".close-btn").click(function(){
                $(lay).fadeOut();
                shadow_div.fadeOut();

            });

            return lay;
        },


    };
    $.fn.tooltip = function(method){
        if(methods[method]){
            return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
        }else if(typeof method === 'object' || !method){
            return methods.init.apply(this,arguments);
        }else{
            $.error('Method'+method+'does not exist on jQuery.tooltip');
        }
    }
})(jQuery);